import React, { Component } from "react";

export default class MyComponent extends Component {
    constructor(props) {
        super(props);
        this.state = {
            hello: "hello world",
        };
        this.handleClick = this.handleClick.bind(this)
    }
    
    handleClick(){
        this.setState({hello:"hello react"})
    }

    // handleClick = () => {
    //     this.setState({hello:"hello react"})
    // }



    render() {
        const { hello } = this.state;
        return (
            <>
                <div>{hello}</div>
                {/* 不需要加括号 */}
                <button onClick={this.handleClick}>点击修改</button>
            </>
        );
    }
}
